#!/bin/bash
if [ ! -n "${1}" ]; then
    exit 0;
fi
access=`sed -n "/${1}/,$ p" /var/nas/nginx/logs/access.log`
if [ -z "$access" ]; then
	echo "{}";
    exit 0
fi

echo $access | goaccess -o json -q --hour-spec=min --ignore-panel=VISITORS --ignore-panel=REQUESTS --ignore-panel=REQUESTS_STATIC --ignore-panel=NOT_FOUND --ignore-panel=HOSTS  --ignore-panel=OS --ignore-panel=BROWSERS --ignore-panel=REFERRING_SITES --ignore-panel=KEYPHRASES --ignore-panel=GEO_LOCATION --ignore-panel=STATUS_CODES